package com.example.neo4j.repository;

import com.example.neo4j.pojo.node.Share;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;

import java.util.List;

public interface ShareRepository extends Neo4jRepository<Share, Long> {

    @Query("match (user:User) where user.account=$account\n" +
            "create (share:Share{publishaccount:$account,publisher:$publisher,publisherimg:$publisherimg," +
            "title:$title,content:$content,related_hobby:$related_hobby,hobbyid:$hobbyid,imgurl:$imgurl,time:$time,address:$address})\n" +
            "create (user)-[publish:Publish]->(share) return share")
    Share publishShare(String account, String publisher, String publisherimg, String title, String content, String related_hobby, Long hobbyid, String imgurl, String address, String time);


    @Query("match(u:User{account:$account})-[:Follow]->(users)-[:Publish]->(shares) return shares")
    List<Share> getFriendShares(String account);
}
